import table from '@/components/dt/table/render.js'
import Opt from '@/components/dt/info/Opt.js'
import houseOpt from '@/biz/option/house.js'
import dateOpt from '@/biz/option/date.js'
import nameOpt from '@/biz/option/name.js'

let _this = null

class Column extends Opt {
  constructor(vm) {
    super()
    _this = vm
    this.build()
  }

  build() {
    this.createAll()
    this.opts.push(...this.all)
  }

  createAll() {
    this.all = [
      {
        title: '所属公司',
        field: 'companyName',
        minWidth: 150
      },
      {
        title: '所属事业处',
        field: 'officeName',
        minWidth: 150
      },
      {
        title: '所属案场',
        field: 'housesName',
        minWidth: 150,
        header: {
          filter: {
            key: 'housesName',
            title: '案场',
            input: {},
            placeholder: '请输入案场'
          }
        }
      },
      {
        title: '人员',
        field: 'userInfo',
        minWidth: 140,
        header: {
          filter: {
            key: 'userInfo',
            title: '人员',
            input: {},
            placeholder: '请输入人员名称或工号'
          }
        }
      },
      {
        title: '笔记',
        field: 'contentText',
        minWidth: 250
      },
      {
        title: '更新时间',
        field: 'updateTime',
        minWidth: 180,
        cell: {
          text: {}
        }
      },
      {
        title: '敏感词校验',
        field: 'checkStateStr',
        minWidth: 130,
        header: {
          filter: {
            title: '敏感词校验',
            key: 'checkState',
            placeholder: '请选择',
            select: {
              options: [
                { key: '0', value: '未通过' },
                { key: '1', value: '通过' }
              ]
            }
          }
        }
      },
      {
        title: '分享次数',
        field: 'shareCount',
        minWidth: 130
      },
      {
        title: '微信好友阅读量',
        field: 'wechatReadCount',
        minWidth: 150
      },
      {
        title: '朋友圈阅读量',
        field: 'momentsReadCount',
        minWidth: 130
      },
      {
        title: '状态',
        field: 'stateStr',
        minWidth: 100,
        header: {
          filter: {
            title: '状态',
            key: 'state',
            placeholder: '请选择',
            select: {
              options: [
                { key: '0', value: '上架中' },
                { key: '1', value: '已下架' }
              ]
            }
          }
        }
      },
      {
        title: '操作',
        fixed: 'right',
        minWidth: 130,
        align: 'center',
        slots: {
          default: (params, h) => {
            let btns = []
            btns.push({
              title: '查看',
              event: 'viewFun',
              data: params.row
            })
            if (params.row.state == '0' && _this.unlocking('0207030701')) {
              btns.push({
                title: '下架',
                event: 'delFun',
                data: params.row
              })
            }
            return table.cell.btns(_this, h, btns)
          }
        }
      }
    ]
  }
}

export default Column
